const {logger} = require('../../utils/log')
const http = require('http')
console.log(logger)
debugger
// 创建http服务
const server = http.createServer((request, response) => {
  // 从请求者信息中获得url
  const {url} = request
  logger.debug(url)
  // 处理该请求
  // text/html --> 默认的content-type
  // application/json;charset=utf-8 --> json对象格式
  response.writeHead(200, {
    'content-type': 'application/json;charset=utf-8',
  })
  // 传递json给前端
  response.write(`{"url" : "${url}"}`)
  // 结束本次请求
  response.end()
})

server.listen(8090, () => {
  console.log('服务已启动：localhost:8090')
})
